﻿namespace GarageManagement.Migrations
{
    using System;
    using System.Data.Entity.Migrations;

    public partial class AddCustomerTypeTable : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.CustomerType",
                c => new
                    {
                        CustomerTypeId = c.Int(nullable: false, identity: true),
                        Name = c.String(maxLength: 1024),
                    })
                .PrimaryKey(t => t.CustomerTypeId);

            Sql("Insert into CustomerType(Name) Values('Khách lẻ')");
            Sql("Insert into CustomerType(Name) Values('Khách buôn')");
            AddColumn("dbo.Customer", "CustomerTypeId", c => c.Int(nullable: false, defaultValue: 1));
            AddForeignKey("dbo.Customer", "CustomerTypeId", "dbo.CustomerType", "CustomerTypeId", cascadeDelete: true);
            CreateIndex("dbo.Customer", "CustomerTypeId");
            DropColumn("dbo.Customer", "IsAgent");
            DropColumn("dbo.Customer", "IsPersonal");
        }

        public override void Down()
        {
            AddColumn("dbo.Customer", "IsPersonal", c => c.Boolean(nullable: false));
            AddColumn("dbo.Customer", "IsAgent", c => c.Boolean(nullable: false));
            DropIndex("dbo.Customer", new[] { "CustomerTypeId" });
            DropForeignKey("dbo.Customer", "CustomerTypeId", "dbo.CustomerType");
            DropColumn("dbo.Customer", "CustomerTypeId");
            DropTable("dbo.CustomerType");
        }
    }
}
